package com.mxpio.erp.common.technology.entity;

import java.math.BigDecimal;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.mxpio.erp.common.inventory.entity.SupplyChain;
import com.mxpio.erp.common.inventory.entity.Warehouse;
import com.mxpio.erp.common.jpa.policy.ResCodeGeneratorPolicy;
import com.mxpio.erp.common.quality.entity.InspectionSchemeChain;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_INVENTORY_ITEM")
@Schema(description="物料")
public class Item extends BaseEntity {

	private static final long serialVersionUID = 1L;
	
	@Id
	@Generator(policy = ResCodeGeneratorPolicy.class)
	@Column(name = "ITEM_CODE_", updatable = false)
	@Schema(description = "物料编码")
	private String itemCode;
	
	@Column(name = "ITEM_NAME_")
	@Schema(description = "物料名称")
	private String itemName;
	
	@Column(name = "ITEM_GROUP_CODE_")
	@Schema(description = "物料组")
	@Dict(dicCode="groupCode", dicEntity = ItemGroup.class, dicText = "groupName")
	private String itemGroupCode;
	
	@Column(name = "ITEM_SPEC_")
	@Schema(description = "物料规格")
	private String itemSpec;
	
	@Column(name = "DRAWING_NO_")
	@Schema(description = "图号")
	private String drawingNo;
	
	@Column(name = "DRAWING_FILE_NO_")
	@Schema(description = "图档号")
	private String drawingFileNo;
	
	@Column(name = "UNIT_CODE_")
	@Schema(description = "单位编号")
	@Dict(dicCode="ERP_TECH_UNIT_CODE")
	private String unitCode;
	
	@Column(name = "SACLE_")
	@Schema(description = "数量精度")
	private Integer scale = 0;
	
	@Column(name = "ITEM_SOURCE_")
	@Schema(description = "物料来源")
	@Dict(dicCode="ERP_TECH_ITEM_SOURCE")
	private String itemSource;
	
	@Column(name = "VIRTUAL_PART_")
	@Schema(description = "是否虚拟件")
	@Dict(dicCode = "ERP_COMMON_YESNO")
	private String virtualPart;
	
	@Column(name = "MATERIAL_")
	@Schema(description = "是否材料")
	@Dict(dicCode = "ERP_COMMON_YESNO")
	private String material;
	
	@Column(name = "ABC_CODE_")
	@Schema(description = "ABC码")
	private String abcCode;
	
	@Transient
	private List<SupplyChain> supplyChains;

	@Transient
	private List<InspectionSchemeChain> inspectionSchemeChains;

	@Column(name = "ITEM_PRICE_")
	@Schema(description = "物料价格")
	private BigDecimal itemPrice;
	
	@Column(name = "IMG_FILE_")
	@Schema(description = "图片路径")
	private String imgFile;
	
	@Column(name = "MEMO_")
	@Schema(description = "备注")
	private String memo;


	@Column(name = "DEFAULT_WH_CODE_")
	@Schema(description = "默认仓库编号")
	@Dict(dicCode = "whCode" ,dicEntity = Warehouse.class, dicText = "whName")
	private String defaultWhCode;

	@Column(name = "MAIN_WORKSHOP_")
	@Schema(description = "主制车间")
	@Dict(dicCode = "workShopCode",dicEntity = WorkShop.class,dicText = "workShopName")
	private String mainWorkshop;

	@Column(name = "MANUFACTURE_ABLE_")
	@Schema(description = "可自制")
	@Dict(dicCode = "ERP_COMMON_YESNO")
	private String manufactureAble;

	@Column(name = "OUTSOURCE_ABLE_")
	@Schema(description = "可委外")
	@Dict(dicCode = "ERP_COMMON_YESNO")
	private String outsourceAble;

	@Column(name = "WORK_CENTER_CODE_")
	@Schema(description = "工作中心")
	@Dict(dicCode = "workCenterCode",dicEntity = WorkCenter.class,dicText = "workCenterName")
	private String workCenterCode;

	@Column(name = "MATERIAL_BRAND_")
	@Schema(description = "材料牌号")//240117 该字段由ItemMaterialProp移至主表对象中
	private String materialBrand;

	@Column(name = "SALE_ABLE_")
	@Schema(description = "可销售")
	@Dict(dicCode = "ERP_COMMON_YESNO")
	private String saleAble;

	@Column(name = "LEND_PERMIT_")
	@Schema(description = "允许借用")
	@Dict(dicCode = "ERP_COMMON_YESNO")
	private String lendPermit;
}
